﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
public partial class DrawRectangle : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int width = 400, hight = 250;
        using (Bitmap image=new Bitmap(width,hight))
        {
            using (Graphics g=Graphics.FromImage(image))
            {
                Rectangle rect = new Rectangle(0, 0, 100, 100);
                using (Pen pen1=new Pen(Color.Blue))
                {
                    g.Clear(Color.White);
                    g.DrawRectangle(pen1, rect);
                    g.DrawRectangle(pen1, 110, 0, 100, 100);
                    image.Save(this.Server.MapPath("temp\\" + "Rectangles.Png"),
                        System.Drawing.Imaging.ImageFormat.Png);
                    Image1.ImageUrl = "temp\\Rectangles.Png";
                }
            }
        }
    }
}